import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, map } from 'rxjs';
import { AnyJson } from './data-types/common.type';
import { ServicesModule } from './services.module';

@Injectable({
  providedIn: ServicesModule,
})
export class SchNewsService {
  constructor(private http: HttpClient) {}
  insertSchNews(body: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/SchNews/insertSchNews', body)
      .pipe(map((res) => res as AnyJson));
  }
  getSchNewsMsgById(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/SchNews/getSchNewsMsgById', { params })
      .pipe(map((res) => res as AnyJson));
  }
  updateSchNews(body: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/SchNews/updateSchNews', body)
      .pipe(map((res) => res as AnyJson));
  }
  likeNews(body: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/SchNews/likeNews', body)
      .pipe(map((res) => res as AnyJson));
  }
  getSchNewsTitleByLid(params: AnyJson, body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/SchNews/getSchNewsTitleByLid', body, { params })
      .pipe(map((res) => res as AnyJson));
  }
  clearSchSortByLid(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/SchNews/clearSchSortByLid', { params })
      .pipe(map((res) => res as AnyJson));
  }
  delSchNews(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/SchNews/delSchNews', { params })
      .pipe(map((res) => res as AnyJson));
  }

  getNewsByRecomSid(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/schNewsRecom/getNewsByRecomSid', { params })
      .pipe(map((res) => res as AnyJson));
  }
  recomNews(body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/schNewsRecom/recomNews', body)
      .pipe(map((res) => res as AnyJson));
  }
  getSchNewsRecomSort(): Observable<AnyJson> {
    return this.http
      .get('/menu/getSchNewsRecomSort')
      .pipe(map((res) => res as AnyJson));
  }
}
